package com.edu.d7_sort_binarysearch;

import java.util.Arrays;

/**
 * 选择排序
 */
public class Test {
    public static void main(String[] args) {
        int[] a={5,1,2,3};
        //外部循环，需要a.length()-1轮
        for (int i = 0; i < a.length-1; i++) {
            for (int j = i+1; j <a.length; j++) {
                /**
                 * i=0,1,2,3
                 * j=1,2,3,4
                 */
                if(a[i]>a[j]){
                    int temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(a));
    }
}
